using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TableSceneDao:DaoBase<TableScene>
    {
        public override void AddPrimaryIndex(TableScene model)
        {
            cachePrimary[model.SceneId.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TableScene.txt";
        }

        protected override TableScene ParseRowData(string[] rowData)
        {
            TableScene data = new TableScene();
			data.SceneId = rowData [0];
			data.sceneMusic = rowData [1];

            if (string.IsNullOrEmpty(rowData[2]))
            {
                data.sceneType = 0;
            }
            else
            {
                data.sceneType = int.Parse(rowData[2]);
            }
			data.minimapRes = rowData [3];

            if (string.IsNullOrEmpty(rowData[4]))
            {
                data.miniMapScale = 0;
            }
            else
            {
                data.miniMapScale = double.Parse(rowData[4]);
            }

            if (string.IsNullOrEmpty(rowData[5]))
            {
                data.miniMapOffsetX = 0;
            }
            else
            {
                data.miniMapOffsetX = double.Parse(rowData[5]);
            }

            if (string.IsNullOrEmpty(rowData[6]))
            {
                data.miniMapOffsetY = 0;
            }
            else
            {
                data.miniMapOffsetY = double.Parse(rowData[6]);
            }

            return data;
        }


        public override void AddOneIndex(TableScene model)
        {
            if (!cacheOneIndex.ContainsKey(model.sceneType.ToString()))
            {
                cacheOneIndex[model.sceneType.ToString()] = new List<TableScene>();
            }
            cacheOneIndex[model.sceneType.ToString()].Add(model);
        }
    

    }

}
